﻿<Page
    x:Name="PageRoot"
    x:Class="PrintingAndScanningExample.MainPage"
    DataContext="{Binding ViewModel, RelativeSource={RelativeSource Self}}"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:PrintingAndScanningExample"
    xmlns:common="using:PrintingAndScanningExample.Common"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DataContext="{d:DesignInstance Type=local:SamplePicturesViewModel, IsDesignTimeCreatable=True}">
    <Page.BottomAppBar>
        <CommandBar>
            <AppBarButton Icon="Preview" Label="Print Preview" Command="{Binding PrintPreviewCommand}"/>
            <AppBarButton Icon="Scan" Label="Scan" Click="HandleScanButtonClicked">
                <FlyoutBase.AttachedFlyout>
                    <Flyout>
                        <local:ScanningControl/>
                    </Flyout>
                </FlyoutBase.AttachedFlyout>
            </AppBarButton>
            <AppBarButton Icon="Camera" Label="Add Pictures" Command="{Binding AddPicturesCommand}"/>
            <!--<AppBarButton Icon="OpenFile" Label="Add Picture"/>-->
            
            <CommandBar.SecondaryCommands>
                <AppBarButton Icon="Delete" Label="Remove" Command="{Binding DeleteCurrentPictureCommand}"/>
            </CommandBar.SecondaryCommands>
        </CommandBar>
    </Page.BottomAppBar>

    <!--
        This grid acts as a root panel for the page that defines two rows:
        * Row 0 contains the back button and page title
        * Row 1 contains the rest of the page layout
    -->
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Grid.ChildrenTransitions>
            <TransitionCollection>
                <EntranceThemeTransition/>
            </TransitionCollection>
        </Grid.ChildrenTransitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="140"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!-- Back button and page title -->
        <Grid Grid.Row="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="120"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Button x:Name="BackButton" Margin="39,59,39,0" Command="{Binding NavigationHelper.GoBackCommand, ElementName=PageRoot}"
                        Style="{StaticResource NavigationBackButtonNormalStyle}"
                        VerticalAlignment="Top"
                        AutomationProperties.Name="Back"
                        AutomationProperties.AutomationId="BackButton"
                        AutomationProperties.ItemType="Navigation Button"/>
            <TextBlock x:Name="PageTitle" Text="{StaticResource AppName}" Style="{StaticResource HeaderTextBlockStyle}" Grid.Column="1" 
                        IsHitTestVisible="false" TextWrapping="NoWrap" VerticalAlignment="Bottom" Margin="0,0,30,40"/>
        </Grid>
        <Grid Grid.Row="1" Margin="40,0,40,40">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <TextBlock Grid.Row="0" Text="Select some pictures to print by using the options available from the app bar, below." Style="{StaticResource SubheaderTextBlockStyle}" Margin="0,0,0,10"></TextBlock>
                <FlipView Grid.Row="1" ItemsSource="{Binding Pictures}" SelectedItem="{Binding CurrentPicture, Mode=TwoWay}">
                    <FlipView.ItemTemplate>
                        <DataTemplate>
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition Width="*" />
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="*" />
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>
                                <Image Grid.Row="0" Grid.Column="0" Source="{Binding Thumbnail}"
                                       VerticalAlignment="Center" HorizontalAlignment="Center" Width="100" />
                                <Image Grid.Row="0" Grid.Column="1" Source="{Binding Picture}" />
                                <StackPanel Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Orientation="Horizontal"
                                            HorizontalAlignment="Center">
                                    <TextBlock Text="Caption: " VerticalAlignment="Center" FontSize="16" />
                                    <TextBox Text="{Binding Caption}" Margin="5" />
                                </StackPanel>
                            </Grid>
                        </DataTemplate>
                    </FlipView.ItemTemplate>
                </FlipView></Grid>
        </Grid>
    </Grid>
</Page>
